<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <h1>窗口开关</h1>
    <button onclick="open_win()">打开窗口</button>
    <button onclick="close_win()">关闭子窗口</button>
    <button onclick="windsow.close()">关闭当前窗口</button>
</body>
<script>
    var newwin;
    function open_win() {
        newwin=window.open("https://www.zhihuishu.com/","new","heingt=400,width=400,top=0,left=0")        
    }
    function close_win(){
        if(newwin&&!newwin.closed){
            newwin.close();
        }
    }
</script>
</html>